<template>
    <div class="wrap">
        <div class="item">
            <div ref="top" :class="['top',toTop?'top-change':'']" @click="changeTop"></div>
            <div ref="middle" :class="['middle',toTop?'middle-change':'']" @click="changeMiddle"></div>
            <!--   -->
            <div ref="bottom" v-if="show" :class="['bottom',toTop?'bottom-change':'']" ></div>
        </div>
    </div>
</template>
<style scoped>
    .wrap {
        align-items: center;
        margin-top: 200px;
    }

    .item {
        width: 600px;
        height: 800px;
        overflow: hidden;
        background-color: aqua;
        align-items: center;
    }

    .top {
        width: 500px;
        height: 700px;
        margin-top: 100px;
        background-color: blueviolet;

        transition-property: width;
        transition-duration: 1000;
        transition-delay: 0;
        transition-timing-function: 'ease';
    }

    .top-change {
        width: 600px;
    }

    .middle {
        width: 600px;
        height: 700px;
        position: absolute;
        top: 0px;
        left: 0px;
        background-color: #2ee378;

        transition-property: width,left;
        transition-duration: 1000;
        transition-delay: 0;
        transition-timing-function: 'ease';
    }

    .middle-change {
        width: 500px;
        left: 50px;
    }

    .bottom {
        width: 600px;
        height: 700px;
        opacity: 0;
        position: absolute;
        top: 0px;
        left: 0px;
        background-color: blueviolet;

        transition-property: opacity;
        transition-duration: 1500;
        transition-delay: 0;
        transition-timing-function: 'ease';
    }

    .bottom-change {
        opacity: 1;
    }

</style>
<script>
const animation = weex.requireModule('animation');
export default {
    data(){
        return{
            isChange: false,
            position: 'relative',
            toTop: false,
            show: false
        }
    },
    methods:{
        changeMiddle(){
            var vm = this;
            var top = vm.$refs.top;
            var middle = vm.$refs.middle;
            var bottom = vm.$refs.bottom;
            vm.toTop = false;
            animation.transition(top,{
                styles:{
                    transform: 'translateY(0px)'
                },
                duration: 1000,
                timingFunction: 'ease'
            })
            animation.transition(middle,{
                styles:{
                    transform: 'translateY(0px)'
                },
                duration: 1000,
                timingFunction: 'ease'
            })
            setTimeout(() => {
                vm.show = false;
            },1000)
        },
        changeTop(){
            var vm = this;
            var top = vm.$refs.top;
            var middle = vm.$refs.middle;
            var bottom = vm.$refs.bottom;
            vm.show = true;
            setTimeout(() => {
                vm.toTop = true;
                animation.transition(top,{
                    styles:{
                        transform: 'translateY(-100px)'
                    },
                    duration: 1000,
                    timingFunction: 'ease'
                })
                animation.transition(middle,{
                    styles:{
                        transform: 'translateY(100px)'
                    },
                    duration: 1000,
                    timingFunction: 'ease'
                })
            },200);
            
            
        }
    }
}
</script>

